<?php $__env->startSection('content-header'); ?>
@parent
          <h1>
            用户管理
            <small>角色</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="<?php echo e(site_url('dashboard', 'admin')); ?>"><i class="fa fa-dashboard"></i> 主页</a></li>
            <li><a href="<?php echo e(_route('admin:role.index')); ?>">用户管理 - 角色</a></li>
            <li class="active">修改角色</li>
          </ol>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

          <?php if(session()->has('fail')): ?>
            <div class="alert alert-warning alert-dismissable">
              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
              <h4>  <i class="icon icon fa fa-warning"></i> 提示！</h4>
              <?php echo e(session('fail')); ?>

            </div>
          <?php endif; ?>

          <?php if($errors->any()): ?>
            <div class="alert alert-danger alert-dismissable">
                  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                  <h4><i class="icon fa fa-ban"></i> 警告！</h4>
                  <ul>
                    <?php foreach($errors->all() as $error): ?>
                    <li><?php echo e($error); ?></li>
                    <?php endforeach; ?>
                  </ul>
            </div>
          <?php endif; ?>

              <h2 class="page-header">修改角色</h2>
              <form method="post" action="<?php echo e(_route('admin:role.update', $role->id)); ?>" accept-charset="utf-8">
              <?php echo method_field('put'); ?>

              <?php echo csrf_field(); ?>

              <div class="nav-tabs-custom">
                  
                  <ul class="nav nav-tabs">
                    <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">主要内容</a></li>
                  </ul>

                  <div class="tab-content">
                    
                    <div class="tab-pane active" id="tab_1">
                      <div class="form-group">
                        <label>角色名 <small class="text-red">*</small>  <span class="text-green small">只能为英文单词，建议首字母大写</span></label>
                        <input type="text" class="form-control" name="name" autocomplete="off" value="<?php echo e(old('name', isset($role) ? $role->name : null)); ?>" placeholder="角色(用户组)名">
                      </div>
                      <div class="form-group">
                        <label>角色展示名 <small class="text-red">*</small> <span class="text-green small">展示名可以为中文</span></label>
                        <input type="text" class="form-control" name="display_name" autocomplete="off" value="<?php echo e(old('display_name', isset($role) ? $role->display_name : null)); ?>" placeholder="角色(用户组)展示名">
                      </div>
                      <div class="form-group">
                        <label>角色描述</label>
                        <textarea class="form-control" name="description" cols="45" rows="2" maxlength="200" placeholder="角色(用户组)描述" autocomplete="off"><?php echo e(old('description', isset($role) ? $role->description : null)); ?></textarea>
                      </div>
                      <div class="form-group">
                        <label>关联权限 <small class="text-red">*</small></label>
                        <div class="input-group">
                          <?php foreach($permissions as $index => $per): ?>
                            <?php if(starts_with($per->name, '@') && $index !== 0): ?>
                            <br>
                            <?php endif; ?>
                            <input type="checkbox" name="permissions[]" value="<?php echo e($per->id); ?>" <?php echo e((check_array($cans,'id', $per->id) === true) ? 'checked' : ''); ?>>
                            <label class="choice" for="permissions[]" data-value="<?php echo e($per->id); ?>" style="cursor: pointer;"><span class="text-green"><?php echo e($per->name); ?></span>[<span class="text-red"><?php echo e($per->display_name); ?></span>]</label>
                          <?php endforeach; ?>
                        </div>
                      </div>
                    </div><!-- /.tab-pane -->

                    <button type="submit" class="btn btn-primary">修改角色</button>

                  </div><!-- /.tab-content -->
                  
              </div>
              </form>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('extraPlugin'); ?>

  <!--引入iCheck组件-->
  <script src="<?php echo e(_asset(ref('icheck.js'))); ?>" type="text/javascript"></script>

<?php $__env->stopSection(); ?>


<?php $__env->startSection('filledScript'); ?>
        <!--启用iCheck响应checkbox与radio表单控件-->
        $('input[name="permissions[]"]').iCheck({
          checkboxClass: 'icheckbox_flat-blue',
          increaseArea: '20%', // optional
        });

        <!--响应点击label 选中或者取消选中-->
        $('label.choice').click(function() {
            var value = $(this).data('value');
            $('input[name="permissions[]"][value='+value+']').iCheck('toggle');
        });
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layout._back', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>